//package fr.umlv.galcon.utils;
//
//import java.io.File;
//import java.io.IOException;
//
//import org.jdom2.Document;
//import org.jdom2.Element;
//import org.jdom2.JDOMException;
//import org.jdom2.input.SAXBuilder;
//
//import fr.umlv.galcon.game.GalconManager;
//import fr.umlv.galcon.player.Player;
//import fr.umlv.galcon.player.PlayerType;
//
//public class XMLReader {
//    private final Document document;
//    private final Element racine;
//
//    private final SAXBuilder sxb;
//
//    public XMLReader(String fileName) throws JDOMException, IOException {
//	this.sxb = new SAXBuilder();
//	this.document = sxb.build(new File(fileName));
//	this.racine = document.getRootElement();
//    }
//
//    public void readFile() {
//	Element players = racine.getChild("players");
//	for (Element player : players.getChildren()) {
//	    System.out.println("id : " + player.getAttributeValue("name") + " " + player.getAttributeValue("id"));
//	    // createPlanets(player.getAttributes());
//	    GalconManager.addPlayer(createPlayer(player), 1);
//	}
//    }
//
//    private void createPlanets(Element planet) {
//	// Planet planet = new Planet(x, y, size, owner, shipProperties,
//	// nbShips, productionRate);
//    }
//
//    /**
//     * Return an instance of player.
//     * 
//     * @param id
//     *            ID of the player.
//     * @param name
//     *            Name of the player.
//     * @param typePlayer
//     *            Type of the player.
//     * @return The created player.
//     */
//    public Player createPlayer(Element player) {
//	int id = Integer.parseInt(player.getAttributeValue("id"));
//	String name = player.getAttributeValue("name");
//	String typePlayer = player.getAttributeValue("type");
//	for (PlayerType p : PlayerType.values()) {
//	    PlayerType pl = PlayerType.valueOf(typePlayer);
//	    if (p.equals(pl))
//		return new Player(pl, name, id);
//	}
//	System.err.println("The player " + id + " : " + name + "doesn't exist");
//	return null;
//    }
// }
